package top.toptimus.dto.store;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import top.toptimus.dto.order.orderSync.orderCommit.OrderCommitDto;

import java.util.UUID;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class SalesConfirmationEntryDTO {
    private String id;//分录id
    private String styleId;//款号
    private String materialNo;//面料号
    private String size;//型号
    private Integer quantity;//数量
    private double price;//单价
    private double totalPrice;//总金额
    private String salesTypeId;//销售类型id
    private String expressId;//发运方式id
    private String titleId;//表头id
    private String orderId; //  订单id

    /**
     * 表头id注入
     *
     * @param titleId 表头id
     * @return 分录
     */
    public SalesConfirmationEntryDTO buildTitleId(String titleId) {
        this.titleId = titleId;
        return this;
    }

    /**
     * 订单id注入
     *
     * @param orderId 订单id
     */
    public void buildOrderId(String orderId) {
        this.orderId = orderId;
    }

    /**
     * 坚山下单用
     *
     * @param orderCommitDto orderCommitDto
     */
    public SalesConfirmationEntryDTO(OrderCommitDto orderCommitDto) {
        this.id = UUID.randomUUID().toString();
        this.styleId = orderCommitDto.getRefStyleId();
        this.materialNo = orderCommitDto.getMaterialCode();
        this.size = orderCommitDto.getStyleSizeCd().substring(15);
        this.quantity = orderCommitDto.getOrderNumber().intValue();
    }
}
